package cn.com.huzo.repository.trade.impl;

import cn.com.huzo.model.entities.trade.SalesContractLinesEntity;
import huzofw.repository.impl.GenericRepositoryImpl;
import huzofw.repository.impl.MyBatisDaoUtils;
import cn.com.huzo.repository.trade.SalesContractLinesRepository;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;

/**
 * 售货合同明细数据访问对象。
 *
 * @author 范学春
 */
@Repository("SalesContractLinesRepository")
public class SalesContractLinesRepositoryImpl extends GenericRepositoryImpl<SalesContractLinesEntity, String>
        implements SalesContractLinesRepository {

    private final String namespace = "cn.com.huzo.repository.trade.SalesContractLinesRepository";

    /**
     * 构造函数,设置the instance to ProductRepositoryImpl.class.
     */
    public SalesContractLinesRepositoryImpl() {
        super(SalesContractLinesEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<SalesContractLinesEntity> fetchByHeaderId(Long headerId) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchByHeaderId"), headerId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public List<SalesContractLinesEntity> fetchByCondition(Map<String, Object> condition) {
        return getSqlSession().selectList(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchByCondition"), condition);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Float fetchTotalAmount(Long HeaderId) {
        return getSqlSession().selectOne(MyBatisDaoUtils.getMapperQueryId(
                namespace, "fetchTotalAmount"), HeaderId);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchInsert(List<SalesContractLinesEntity> itemsList) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchInsert"), itemsList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer batchUpdate(List<SalesContractLinesEntity> itemList) {
        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "batchUpdate"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer delete(String key) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "delete"), key);
    }
}
